
#ifndef __MINI_TREE_H__
#define __MINI_TREE_H__

#include "mini_list.h"

#define MINI_TREE_OK       0
#define MINI_TREE_ERR      1

typedef struct mini_tree_node
{
    list_head_t list;
    list_head_t c;
    struct mini_tree_node *f;
    void *data;
} mini_tree_node_t, *mini_tree_node_p;

#define MINI_TREE_MAX_DEEP  5

#define MINI_TREE_SAME      0
#define MINI_TREE_DIFF      1
typedef int (*mini_tree_compare_pf)(void *data, void *cmp);
typedef void (*mini_tree_show_pf)(void *data);
typedef int (*mini_tree_call_pf)(void *data);

mini_tree_node_t *mini_tree_create_node(int datalen);

void mini_tree_free_tree(mini_tree_node_t *n);
void mini_tree_free_node(mini_tree_node_t **n);
mini_tree_node_t *mini_tree_find(mini_tree_node_t *f, void *data, mini_tree_compare_pf compare);
mini_tree_node_t *mini_tree_find_child(mini_tree_node_t *f, void *data, mini_tree_compare_pf compare);
int mini_tree_list(mini_tree_node_t *n, mini_tree_call_pf call);
void mini_tree_insert(mini_tree_node_t *f, mini_tree_node_t *c);
void mini_tree_dump(mini_tree_node_t *f, mini_tree_show_pf show, int depth);

#endif /* __MINI_TREE_H__ */

